<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue.js"></script>
    <style>
        a {
            display: none;
            text-align: center;
        }
    </style>

</head>

<body>
    <div class="div">
        <!-- <div @click="click" :class="classnames">胡歌</div> -->


        <!-- 第一种方法   注： 如果中间用杆分开就得放引号里面 'background-color':'red-->
        <!-- <div :style="{width:'200px',height:'200px',backgroundColor:'red'}"></div> -->
        <!-- <div @click="click" :style="style">胡歌999999</div> -->
        <div @click="click" :style="arrs">000</div>
    </div>
    <script>

        const obj = {
            data() {
                return {
                    // 对象动态绑定style属性
                    style: {
                        width: '200px',
                        height: '200px',
                        backgroundColor: 'red'
                    },
                    // 数组动态绑定style属性
                    arrs: [
                        {
                            width: '200px',
                            height: '200px',
                            backgroundColor: 'red'
                        },
                        {
                            color: 'white',

                        }
                    ]
                }
            },
            methods: {
                click() {
                    // 点击div为arrs[0]数组对象添加 textAlign='center'
                    this.arrs[0].textAlign = 'center'

                }
            }
        }
        const app = Vue.createApp(obj).mount('.div')
    </script>
</body>

</html>